from easygui import *
import sys
import cPAMIE as PAMIE 
import cReport
# Initialize our stuff.
rep = cReport.Report()
rep.initialize()
ie = PAMIE.PAMIE()
ie.showDebugging = True
rep.status ("Starting...!")

#~~~~~~~~~~~~~~~~~~~~~
# The startGUI Class.
#~~~~~~~~~~~~~~~~~~~~~

def UserPassGUI():  #define our vodafone sign in Function
	rep.status ("in StartGUI()")
	try:
#		while 1:
			msg = "Application will attempt to Login onto www.vodafone.ie with account details and a sent an SMS via your account. Please fill in all fields!"
			title = "Vodafone Application"
			
			fieldNames = ["User Name #","Password"]
			fieldValues = []  # we start with blanks for the values
			fieldValues = multpasswordbox(msg,title, fieldNames)

			# make sure that none of the fields was left blank
			while 1:
			    if fieldValues == None: break
			    errmsg = ""
			    for i in range(len(fieldNames)):
				    if fieldValues[i].strip() == "":
					    errmsg = errmsg + ('"%s" is a required field.\n' % fieldNames[i])
			    if errmsg == "": break # no problems found
			    fieldValues = multpasswordbox(errmsg, title, fieldNames, fieldValues)

			print "User:", 		fieldValues[0] # <<------ Recipient is # fieldValues[0]
			print "Pass:", 		fieldValues[1]

			# rep.status (fieldValues[0])

	except:
		print 'GUI USER&PASS: QUIT!'


def MsgGUI():  #define our vodafone sign in Function
	rep.status ("in MsgGUI()")
	try:
#		while 1:
			msg = "Enter SMS data.\n"
			title = "Vodafone Application"

			fieldNames = ["Recipient","SMS Message"]
			fieldValues = []  # we start with blanks for the values
			fieldValues = multenterbox(msg,title, fieldNames)

			# make sure that none of the fields was left blank
			while 1:
			    if fieldValues == None: break
			    errmsg = ""
			    for i in range(len(fieldNames)):
				    if fieldValues[i].strip() == "":
					    errmsg = errmsg + ('"%s" is a required field.\n' % fieldNames[i])
			    if errmsg == "": break # no problems found
			    fieldValues = multenterbox(errmsg, title, fieldNames, fieldValues)

			print "Recipient:", 	fieldValues[0]
			print "MSG:", 		fieldValues[1]

			# rep.status (fieldValues[0])

	except:
		print 'GUI MSG: QUIT!'

	
if __name__ == '__main__':
	UserPassGUI() 	# call the signIn function
	MsgGUI()	# call the MsgGUI function